package no.uib.hplims.views.settings;

import no.uib.hplims.models.ActionLock;
import no.uib.hplims.tools.Icons;
import no.uib.hplims.tools.PermissionsUtil;
import no.uib.hplims.views.AbstractParentTab;

import com.vaadin.terminal.ThemeResource;
import com.vaadin.ui.Component;
import com.vaadin.ui.VerticalLayout;

public class SettingsTab extends AbstractParentTab {

	private static final long serialVersionUID = -7051823385379887568L;

	private VerticalLayout layout = null;
	
	private static String caption = "Settings";
	
	public SettingsTab() {
		super(caption, Icons.settingsIcon16);

		init();

	}
	
	@Override
	protected void init() {
		// Add general settings
		getMainTab().addComponent(new GeneralSettingsView());
		
		// Add user settings
		Component userSettings;
		ThemeResource icon = null;
		if (PermissionsUtil.hasAccess(ActionLock.MANAGE_USERS)) {
			userSettings = new AdminUserView();
			icon = Icons.usersSettingsIcon;
		} else {
			userSettings = new RegularUserView();
			icon = Icons.userSettingsIcon;
		}
		getTabSheet().addTab(userSettings);
		getTabSheet().getTab(userSettings).setClosable(false);
		getTabSheet().getTab(userSettings).setCaption("User settings");
		getTabSheet().getTab(userSettings).setIcon(icon);
		
		getTabSheet().addTab(new FreezerSettings());
		getTabSheet().addTab(new ImportLibraryDataView());
		
	}
	
	@Override
	public String toString() {
		return caption;
	}

	

	public void activated(Object... params) {
		// TODO Auto-generated method stub
		
	}

	public void deactivated(Object... params) {
		// TODO Auto-generated method stub
		
	}
}
